package com.tianji.remark.task;

import com.tianji.remark.service.ILikedRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2025/10/28 17:52
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class LikeTimesCheckTask {
    private final ILikedRecordService likedRecordService;
    private final List<String> BIZ_TYPES = List.of("QA", "NOTE");
    private Integer maxBizSize = 30;

    /**
     * 定时检测点赞数并发送MQ消息 至 业务方
     */
    @Scheduled(fixedDelay = 20000)
    public void checkLikeTimes() {
        for (String bizType : BIZ_TYPES) {
            log.info("开始执行点赞数检查任务...当前业务类型：{}，处理条数：{}", bizType, maxBizSize);
            likedRecordService.readLikeTimesAndSendMessage(bizType, maxBizSize);
        }
    }
}
